package view.Arm.tank
{
	import data.Globals;
	
	import flash.events.Event;
	import flash.geom.Point;
	
	import utils.GameUtils;
	
	import view.Arm.BaseTank;
	
	/**
	 *
	 *@author CrazyChen 
	 *2013-4-14
	 */	
	public class CTank extends BaseTank
	{
		public var bullet:Boolean;
		public function CTank()
		{
			cls = CTankCls;
			super();
		}
		
		override protected function shout():void{
			if(!bullet){
				bullet = true;
				Globals.gameView.shoutBullet(bulletType,new Point(this.x,this.y),new Point(shoutTarget.x,shoutTarget.y),this);
			}
		}
		
		override protected function loop(event:Event):void{
			if(isCloseLoop){
				return;
			}
			if(shoutTarget){
				var distance:int = GameUtils.getTwoPointDistance(new Point(shoutTarget.x,shoutTarget.y),new Point(this.x,this.y));
				if(distance > shoutRadius){
					shoutTarget = null;
				}else{
					chechTargetIsDie();
				}
			}
			if(!shoutTarget)findTarget();
			if(shoutTarget){
				shout();
			}
		}
	}
}